package com.atom.process.cnmuseum.cj.dao.process;

import com.atom.common.dao.AvensCommonDao;
import com.atom.common.exception.AvensNullPointerException;
import com.atom.common.remote.user.UserUtil;
import com.atom.process.cnmuseum.cj.entity.process.CjYxxxProcessDO;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by xiaoxiao on 2019/7/25.
 */
@Repository
public class CjYxxxProcessDao extends AvensCommonDao<CjYxxxProcessDO> {
    public CjYxxxProcessDO findByProcessInstanceId(String processId) {
        List<CjYxxxProcessDO> list = super.findByProperty("processId", processId);
        if (list == null || list.size() == 0) {
            throw new AvensNullPointerException("ProcessDO is null where processId = " + processId);
        } else {
            return list.get(0);
        }
    }


    public void createPDO(UserUtil user, String processInstanceId) {
        CjYxxxProcessDO pdo = new CjYxxxProcessDO();
        pdo.setProcessId(processInstanceId);
        super.save(pdo);
    }
}
